<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建课程</title>
    <style>
        .container .kc {
            background-color: #f5f5f5;
        }

        /* .card.col-md-4.ms-3.mt-3:hover{
            background: rgb(241, 240, 240);
        }
        .card.col-md-4.ms-3.mt-3 .mt-1.text-muted:hover,.card.col-md-4.ms-3.mt-3 .card-title:hover{
            color: rgb(97, 172, 172) !important;
        } */
        .link-secondary:hover {
            color: #0d6efd !important;
        }

        .leftmenu {
            min-height: 100vh;
        }
    </style>
</head>

<body>
    <!-- container是bootstrap的居中窄的显示方案 -->
    <div class="container bg-body-secondary">

        <div class="position-fixed bottom-0 end-0">
            <div class="form-control rounded-pill text-primary mb-2"><i class="bi bi-volume-up"></i> 更新公告</div>
            <div class="form-control rounded-pill text-primary mb-2"><i class="bi bi-question-circle-fill"></i> 使用帮助
            </div>
            <div class="form-control rounded-pill text-primary mb-2"><i class="bi bi-person"></i> 在线客服</div>
            <div class="form-control rounded-pill text-primary mb-2"><i class="bi bi-arrow-up-circle-fill"></i> 返回顶部
            </div>
        </div>

        <div class="row">

            <div class="col-md-2 leftmenu" id="leftmenu">
                
            </div>

            <div class="col-md-9 kc ms-3">
                <div class="row mt-3 pb-1 border-bottom border-secondary">
                    <div class="col-md-2">添加课程</div>
                    <div class="col-md-1 offset-md-8">
                        <a class="nav-link link-success" href="javascript:history.back(-1)">返回</a>
                    </div>
                </div>
                <div class="row mt-3">
                    <div class="mb-3 row">
                        <label for="course-number" class="col-sm-2 col-form-label">课程编号:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="course-number">
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label for="course_url" class="col-sm-2 col-form-label">图片:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="course_url">
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label for="course-name" class="col-sm-2 col-form-label">课程名称:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="course-name">
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label for="course-department" class="col-sm-2 col-form-label">院系:</label>
                        <div class="col-sm-10">
                            <select class="form-select" name="" id="course-department">
                                <option selected>-- 请选择院系 --</option>
                                <option value="计算机科技与应用">计算机科技与应用</option>
                                <option value="中文系">中文系</option>
                                <option value="教育系">教育系</option>
                                <option value="旅游与酒店管理">旅游与酒店管理</option>
                                <option value="幼儿师范部">幼儿师范部</option>
                                <option value="音乐系">音乐系</option>
                                <option value="美术系">美术系</option>
                                <option>体育系</option>
                                <option>机电系</option>
                                <option>数学系</option>
                                <option>现代系</option>
                            </select>
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label for="course-teacher" class="col-sm-2 col-form-label">教师:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="course-teacher">
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label for="grade_code" class="col-sm-2 col-form-label">年级:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="grade_code">
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <div class="col-sm-12">
                            <button type="button" class="btn btn-outline-primary" id="submit">提交</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="module" src="../js/main.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/common.js"></script>
    <script>
        $(document).ready(function () {
            // 当用户点击calss是nav-tab的标签给该标签(添加之前删除所有active类)添加active类
            $(".nav-tab").click(function () {
                // 删除nav-tab所有的active类
                $(".nav-tab").removeClass("active");
                // 给电机的标签添加active类
                $(this).addClass("active");
            })
            $("#submit").click(function (e) {
                // 获取提交数据
                // 方式一 获取全部
                // $("#studentForm").serializeArray() 获取form表单中所有要提交的信息
                // console.log($("#studentForm").serializeArray());
                // 方式二 一个一个获取
                let number=$("#course-number").val();
                let course_url=$("#course_url").val();
                let name =$("#course-name").val();
                let yuanxi =$("#course-department").val();
                let teacher =$("#course-teacher").val();
                let code =$("#grade_code").val();
                // console.log(teacher);
                $.post("https://unicloud.codecore.cn/ms/courseCreate", {
                    calss_number:number,
                    course_name: name,
                    course_department:yuanxi,
                    teacher_name:teacher,
                    grade_code:code,
                    course_url:course_url
                }, function (res) {
                    console.log(res);
                    if (res.errCode == 0) {
                        // 提示添加成功
                        location.reload();
                        href=history.back(-1);
                    } else {
                        // 提示添加失败
                    }
                })
            })
        })
    </script>
</body>

</html>